// voicecalltest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <gtest/gtest.h>
#include <iostream>
#include <windows.h>
#include "VoiceCall.h"
using namespace std;
/* Inital the environment for testing*/


_TCHAR* input = _T("10010");

int _tmain(int argc, _TCHAR* argv[])
{
	testing::InitGoogleTest(&argc,argv);
	
	input= argv[argc-1];

	wcout<<"phone number is :"<<input<<endl;

	return RUN_ALL_TESTS();
}

class VoiceCallTest: public testing::Test
{
public:
	static void Setup()
	{
 		pVoiceCall = new VoiceCall();
	}
	static void TearDown()
	{
  		delete pVoiceCall;
	}
	static VoiceCall *pVoiceCall;
};
VoiceCall* VoiceCallTest::pVoiceCall = NULL;
/****************************************************************************************/
//Function: Init the phone device
//Purpose:	Init the TAPI, init the phone, get some info of the device
//Return: If successful occurs, the return value is 0, otherwise it return 1.
/****************************************************************************************/
TEST_F(VoiceCallTest,DialInit)
{
 	EXPECT_EQ(0,pVoiceCall->DialInit());
}
/****************************************************************************************/
//Function: Make a phone call
//Purpose:	Make a phone call to "10010" and hold the call for 15s 
//Return: If successful occurs, the return value is true, otherwise it return false.
/****************************************************************************************/
TEST_F(VoiceCallTest,DialOut)
{
	EXPECT_EQ(true,pVoiceCall->DialOut(input));
	::Sleep(15*1000);
}
/****************************************************************************************/
//Function: Drop the dial
//Purpose:	Terminate the call
//Return: If successful occurs, the return value is true, otherwise it return false.
/****************************************************************************************/
TEST_F(VoiceCallTest,DialDrop)
{
	EXPECT_EQ(true,pVoiceCall->DialDrop());
}